package com.ellricky.baselib.adapter.student;

import android.app.Activity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.cardview.widget.CardView;

import com.andr.common.ui.adapter.BaseRecyclerAdapter;
import com.andr.common.ui.adapter.SmartViewHolder;
import com.andr.common.util.EmptyUtil;
import com.ellricky.baselib.R;
import com.ellricky.baselib.entity.student.StudentApplyEntity;

public class StuApplyAdapter extends BaseRecyclerAdapter<StudentApplyEntity> {

    private Activity ctx;

    public StuApplyAdapter(Activity activity) {
        super(R.layout.base_adapter_common_list);
        ctx = activity;
    }

    @Override
    public void onBindViewHolder(SmartViewHolder holder, StudentApplyEntity model, int position) {

        View itemView = holder.itemView;

        CardView cvRoot = itemView.findViewById(R.id.cvRoot);

        TextView tvTitle = itemView.findViewById(R.id.tvTitle);

        TextView tvKey = itemView.findViewById(R.id.tvKey);
        TextView tvValue = itemView.findViewById(R.id.tvValue);

        TextView tvDateKey = itemView.findViewById(R.id.tvDateKey);
        TextView tvDate = itemView.findViewById(R.id.tvDate);

        ImageView ivEnd = itemView.findViewById(R.id.ivEnd);
        TextView tvAudit = itemView.findViewById(R.id.tvRightText);

        String title = model.getName();
        String applyTypeName = model.getApplyTypeName();
        if (!EmptyUtil.isEmpty(applyTypeName)){
            title += "（" + applyTypeName + "）";
        }
        tvTitle.setText(title);

//        tvKey.setText(ctx.getString(R.string.base_class));
//        tvValue.setText(model.getClassName());

//        tvDateKey.setText(ctx.getString(R.string.base_fz_teacher));
//        tvDate.setText(model.getTearchName());

        tvDateKey.setText("申请状态：");
        tvDate.setText(model.getApproveStatusName());

//        tvAudit.setText(model.getApproveStatusName());

        boolean deal = model.isApplyDeal();
        cvRoot.setSelected(deal);
        tvTitle.setSelected(deal);
        tvKey.setSelected(deal);
        tvValue.setSelected(deal);
        tvDate.setSelected(deal);
        tvDateKey.setSelected(deal);
        tvAudit.setSelected(deal);

        if (deal){
            ivEnd.setVisibility(View.VISIBLE);
            tvAudit.setVisibility(View.GONE);
            ivEnd.setImageResource(R.drawable.base_icon_common_list_white);
        }else{
            ivEnd.setVisibility(View.VISIBLE);
            tvAudit.setVisibility(View.GONE);
            ivEnd.setImageResource(R.drawable.base_icon_common_list);
        }
    }
}
